﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;
using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Tools.Excel;
using Microsoft.Office.Tools;
using MVVM.Core;
using ObjectModel.Excel;
using ViewModels;
using ViewComponents;

namespace LinkedRangesAddIn
{
    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            ObjectModel.Excel.Globals.Application = this.Application;

			LaunchUI();
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
			// Cleanup
        }

        private void LaunchUI() {

        	System.Windows.Forms.Integration.ElementHost host;
            
            //instantiate a manager
            ExcelViewModelManager manager = new ExcelViewModelManager(out host);
            host.Dock = DockStyle.Fill;

            // Create a user control to contain the WPF element host.
            UserControl uc = new UserControl();
            uc.Controls.Add(host);

            // Create a custom task pane.
            CustomTaskPane ctp = CustomTaskPanes.Add(uc, "PS Charts Add-In");
            ctp.Visible = true;
            ctp.Width = 250;
        }

        #region VSTO generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }
        
        #endregion
    }
}
